<template>
    <nut-overlay v-model:visible="props.showO" z-index="9999" :close-on-click-overlay="false">
        <view class="wrapper">
            <view class="c" @click="emit('close', false)">
                <image src="/static/icon/c.png" />
            </view>
            <view class="hb" v-if="props.hb">
                <image :src="props.hb" mode="aspectFill" />
            </view>
            <view v-if="props.hb" class="save dispaly-align-center" @click="sava()">保存图片</view>
            <nut-button v-if="!props.hb" custom-color="#d76457" :loading="props.hb" type="success"
                @click="changeLoading">海报加载中～～</nut-button>
        </view>
    </nut-overlay>
</template>

<script setup>
import { saveImage } from '@/utils/util'

const props = defineProps({
    showO: {
        type: Boolean,
        default: false
    },
    hb: String
})

const emit = defineEmits(['close'])


// 保存图片海报
const sava = () => {
    if (props.hb) {
        saveImage(props.hb)
    } else {
        uni.showToast({
            title: '海报加载中',
            icon: 'none'
        })
    }
}
</script>
<style lang="scss" scoped>
.wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100%;

    .save {
        width: 284rpx;
        height: 66rpx;
        border-radius: 33rpx;
        border: 2rpx solid #FFFFFF;
        font-family: PingFang-SC, PingFang-SC;
        font-weight: bold;
        font-size: 26rpx;
        color: #FFFFFF;
        margin-top: 40rpx;
    }

    .c {
        width: 512rpx;
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20rpx;

        image {
            width: 46rpx;
            height: 46rpx;
        }
    }
}

.hb {
    image {
        width: 512rpx;
        height: 930rpx;
    }
}
</style>